<script src='{$base_dir}js/AJAX_MedicalRecord.js' type='text/javascript' ></script>
<script type='text/javascript'>
{if isset($newRecord)}	
	var canEditEncounter = {$canEditEncounter};						
{/if}
{literal}										

$(document).ready(function() {		
	$('#encounterList').change(function(){		
		$('#encounterList option:selected').each(function () {			
			var val = $(this).val();
			if (val != -1 && val != 0) {
				$('#registrationInfo').hide();
				var prefix = val.charAt(0);
				var suffix = val.substring(1);
				// Openning record
				if (prefix == 'N') {
					viewOpenRecord(suffix, canEditEncounter);					
					$('#buttonBar').show();
				// Closed record	
				} else {
					viewOpenRecord(suffix, 1);
					// Remove the "Closing ticket button"
					$('#buttonBar').hide();
				}
			} else if (val == 0) {
				$('#registrationInfo').show();								
				$('#medicalContent').html('');
				$('#medicalSubRecordMenu').hide();				
			} 
		});
	});
	$('#encounterList').trigger('change');
});
{/literal}
</script>

<div style='display: block; position: relative;'>
	<div id='medicalSubRecordMenu' style="float: left; width: 70%;">
		<table cellspacing='0' cellpadding='0' class='subNavigator' style='width: 100%'>
			<tr>
                <td>
                    <a id='hanhChinh' href='#'>{translate}Hành chính{/translate}</a>
                </td>
				<td class='active'>
					<a id='khamLamSang' href='#'>{translate}Clinical examination{/translate}</a>
				</td>						
				<td>
					<a id='toaThuoc' href='#'>{translate}Prescription{/translate}</a>
				</td>				
				<td class='last'>
					<a id='canLamSang' href='#'>{translate}Paraclinique{/translate}</a>
				</td>
								
			</tr>
		</table>
	</div>
	
    <div style="margin-bottom: 5px; height: 22px; border: none; background: none; float: right;">         
        <select id='encounterList' style='width: 233px;'>
            <optgroup id='newEncounterGroup' label='{translate}Open Record{/translate}'>
            {if isset($newRecord)}
                <option id='newEncounter' value='N{$newRecord.record_id}' selected='selected'>{$newRecord.name}</option>                        
            {else}
                <option id='noEncounter' value='0' selected='selected'>{translate}Not yet{/translate}!</option>
            {/if}
            </optgroup>
            <optgroup id='oldEncounterGroup' label='{translate}Closed Record{/translate}'>
            {if isset($recordTree)}
                {foreach from=$recordTree item=aRecord}
                <option value='O{$aRecord.record_id}'>{$aRecord.name}</option>                      
                {/foreach}
            {else}
                <option value='-1'>{translate}Not yet{/translate}!</option>
            {/if}
            </optgroup>
        </select> &nbsp;         
    </div>
        
    <div style='clear: both; height: 10px;'></div>    	
</div>

<div id='medicalContent'>
        
</div>


<div id="registrationInfo" class="doctor-intro" style="display: none;"> 
	{translate}Patient not register yet. Please register at reception deck.{/translate} 
</div>